using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using DataTransferObject;
using Business;
namespace Presentation.UserControlls
{
    public partial class UC_DangMuonSach : UserControl
    {
        clsDocGiaBUS docgiaBUS = new clsDocGiaBUS();
        clsDocGiaDTO docgiaDTO = new clsDocGiaDTO();
        clsThuThuBUS thuthuBUS = new clsThuThuBUS();
        BindingSource bs = new BindingSource();
        DataTable tbl = new DataTable();
        int tongcong;

        public UC_DangMuonSach()
        {
            InitializeComponent();
        }

        private void groupPanel1_Click(object sender, EventArgs e)
        {

        }

        private void UC_DangMuonSach_Load(object sender, EventArgs e)
        {
            tbl = thuthuBUS.DocGiaBUS.LayDocGiaDangMuonSach();
            tongcong = 0;
            HienThiListView(tbl);
            lbltongcong.Text = Convert.ToString(tongcong);
            if (tongcong == 0)
                btnIn.Enabled = false;
        }
        private void HienThiListView(DataTable tbl1)
        {
            ListViewItem lvwitem = new ListViewItem();
            lvwthongkeanpham.Items.Clear();
            foreach (DataRow dr in tbl1.Rows)
            {
                tongcong = tongcong + 1;
                lvwitem = new ListViewItem();
                lvwitem.Text = dr["MATHE"].ToString();
                lvwitem.SubItems.Add(dr["HOTEN"].ToString());
                DateTime ngaymuon = Convert.ToDateTime(dr["NgayMuon"].ToString());
                DateTime ngayhethan = Convert.ToDateTime(dr["NgayHetHanS"].ToString());
                lvwitem.SubItems.Add(ngaymuon.ToShortDateString());
                lvwitem.SubItems.Add(ngayhethan.ToShortDateString());
                lvwitem.SubItems.Add(dr["TIENNO"].ToString());
                lvwthongkeanpham.Items.Add(lvwitem);
            }


        }
        private void btnThoat_Click(object sender, EventArgs e)
        {
            DialogResult dlg = new DialogResult();
            dlg = DevComponents.DotNetBar.MessageBoxEx.Show("Bạn có muốn thoát không ?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dlg == DialogResult.Yes)
            {
                this.ParentForm.Close();

            }
        }

        private void btnIn_Click(object sender, EventArgs e)
        {
            FromInAn.FrmThongKeDocGiaDangMuonSach TKDocGia = new Presentation.FromInAn.FrmThongKeDocGiaDangMuonSach();
            TKDocGia.Show();
        }
    }
}
